function y = R6dy(x) 
% 
% Dynamic analysis for RRRRRR 3 degree bar group 
% 
% Copyrigl1t 2003 Qu Xiuquan 
% 
% Input parameters 
% 
% x(l) = theta - i 
% x(2) = theta - j 
% x(3) = theta - k 
% x(4) = theta
% x(5) = theta - f 
% x(6) = theta - g 
% x(7) = dtheta
% x(8) = dtheta
% x(9) = dtheta - k 
% x(10) = dtheta - g 
% x(11) = ddtheta
% x(l2) = ddtheta
% x(l3) = ddtheta - k 
% x(l4) = ddtheta - g
% x(15) = Re[ddB] 
% x(l6) = Im[ddB] 
% x(17) = Re[ddE] 
% x(18) = Im[ddE] 
% 
% Output parameters 
% 
% y(l) = RxB 
% y(2) = RyB 
% y(3) = RxC 
% y(4) = Rye 
% y(5) = RxD 
% y(6) = RyD 
% y(7) = RxE 
% y(8) = RyE 
% y(9) = RxF 
% y(lO) = RyF 
% y(ll) = RxG 
% y(12) = RyG 
% 
g=9.8; 
ri=0.4;rj = 0.3;rk = 0.3;rci = 0.2;rcj = 0.15;rck = 0.15;rce = 0.274;rcf= 0.188;rcg = 0.095; 
thgp = 0.5612;thep = 0.1931;thfp = 0.5214; 
mi= 8.5;mj = 7.6;mk = 7.6;ml = 12; 
Ji= 0.09;Jj=0.075;Jk = 0.075;Jl = 0.15; 
ReddC = 0;ImddC = 0;ReddD = 0;ImddD = 0; 
Fxi = 0;Fyi = 0;Fxj = 0;Fyj = 0;Fxk = 0;Fyk = 0;Fxl = 0;Fyl = 0; 
Mi = 0;Mj = 1000;Mk = 1000;Ml = 0; 
a = zeros(12); 
a(1,1) = 1;a(1,7) = 1; 
a(2,2) = 1;a(2,8) = 1; 
a(3, 1) = rci * sin(x(1));a(3,2) = - rci* cos(x(1));a(3,7) = - (ri- rci) * sin(x(1)); 
a(3,8) = (ri-rci) * cos(x(1)) ; 
a(4,3) = 1;a(4,9) = 1; 
a(5,4) = 1;a(5,10) = 1; 
a(6,3) = rcj * sin(x(2)) ;a(6,4) = - rcj * cos(x(2)) ;a(6,9) = - (rj - rcj) * sin(x(2)); 
a(6, 10) = (rj - rcj) * cos(x(2)); 
a(7,5) = 1;a(7,11) = 1; 
a(8,6) = 1;a(8,12) = 1; 
a(9,5) = rck * sin(x(3)) ;a(9,6) = - rck * cos(x(3)) ;a(9, 11) = - (rk - rck) * sin(x(3)); 
a(9, 12) = (rk - rck) * cos(x(3)); 
a(10,7)=-1;a(10,9) =-1;a(10,11) =-1; 
a(11,8) =- 1;a(11,10) =- 1;a(11,12) =-1; 
a(12,7) = -rcg*sin(x(6)+thgp);a(12,8) = rcg*cos(x(6)+thgp); 
a(12,9) = - rce * sin(x(4) + thep) ;a(12, 10) = rce * cos(x(4) + thep); 
a(12, 11) = -rcf*sin(x(5) + thfp) ;a(12,12) =rcf* cos(x(5) + thfp); 
b = zeros(12,1); 
b(1,1) = mi*x(15) +mi*rci*x(11)*cos(x(1) +pi/2) +mi* rci * x(7)^2 * cos(x(1) + pi) - Fxi; 
b(2, 1) = mi* x(16) +mi* rci * x(11) * sin(x(1) + pi/2) + mi*rci*x(7)^2*sin(x(1) + pi)-Fyi + mi* g; 
b(3,1)=Ji*x(11)-Mi
b(4, 1) = mj * ReddC + mj * rcj * x(12) * cos(x(2) + pi/2) + mj * rcj * x(8)^2 * cos(x(2) + pi) - Fxj; 
b(5, 1) = mj * ImddC + mj * rcj * x(12) * sin(x(2) + pi/2) + mj * rcj * x(8)^2 * sin(x(2) + pi) -Fyj + mj * g; 
b(6,1) =Jj*x(12)-Mj; 
b(7, 1) = mk * ReddD + mk * rck * x(13) * cos(x(3) + pi/2) + mk * rck * x(9)^2 * cos(x(3) + pi) - Fxk; 
b(8, 1) = mk * ImddD+ mk * rck * x(13) * sin(x(3) + pi/2) + mk * rck * x(9)^2 * sin(x(3) + pi) -Fyk + mk* g; 
b(9, 1) = Jk * x(13) - Mk; 
b(10,1)=ml*x(17)+ml*rcg*x(14)*cos(x(6)+thgp+pi/2)+ml*rcg*x(10)^2*cos(x(6)+thgp+pi)-Fxl
b(11,1) = ml*x(18) + ml* rcg* x(14) * sin(x(6) + thgp + pi/2) + ml* rcg* x(10)^2 * sin(x(6) + thgp + pi) - Fyl + ml* g; 
b(11,1) = Jl * x(14) - Ml; 
y = inv(a) * b;